﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LoginExpert.aspx.cs" Inherits="RN.ERP.Web.LoginExpert" %>

<%@ Register Src="UserControl/UCUserRight.ascx" TagName="UCUserRight" TagPrefix="ucUserRight" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <link id="myStyleSheet" runat="server" rel="stylesheet" type="text/css" />
    <title>
        <%=PageTitle%></title>
    <link rel="Stylesheet" type="text/css" href="Scripts/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <script type="text/javascript" src="Scripts/jquery.min.js"></script>
    <script type="text/javascript" src="Scripts/ligerUI/js/ligerui.min.js"></script>
    <script src="Scripts/pta.js" type="text/javascript"></script>
    <script src="Scripts/calogin.js" type="text/javascript"></script>
    <script type="text/javascript">



        function keyLogin(e) {
            var e = e || event;
            if (e.keyCode == 13) {
                if ($("#TabTab03Con1").css("display") == "block") {
                    $("#zhuguanLogin").click();
                }
                else {
                    $("#expertLogin").click();
                }
            }
        }
        function setTab03Syn(data) {
            if (data == 1) {
                $("#TabTab03Con1").css("display", "block");
                $("#TabTab03Con2").css("display", "none");
                $("#font2").css("color", "#333333");
            }
            else {
                $("#TabTab03Con2").css("display", "block");
                $("#font2").css("color", "#1269A1");
                $("#TabTab03Con1").css("display", "none");
            }
        }

        function _dialog(type, msg) {
            var h = $(".main").height();
            $.ligerDialog[type](msg);
            $(".main").height(h);
        }

        $(function () {

            if (appid == 97) {
                $('.Register').attr("href", 'http://123.234.82.27/oldytbm/Member/CorpReg');
                $('#RegisterEdit').show();
            } else {
                $('.Register').attr("href", 'RegisterExpert.aspx');
            }

            document.onkeydown = keyLogin;
            var Result = CheckDogCA();

            var str = Result.split(',');
            if ($("select option").length == 0) {
                $("select").css("display", "none");
            }
            else {
                $("select").css("display", "none");
            }
            var ret = GetCACertFirst();
            if (typeof ret == "object") {
                $('#inp_name').val(ret.CommonName);
            }
            $("#zhuguanLogin").click(function () {
                var username = $('#inp_name').val();
                var password = $('#inp_email').val();
                if (username == "" || password == "") {
                    _dialog("error", '用户名或密码不能为空');
                    //radalert('用户名或密码不能为空', 300, 150, '提示');
                }
                else {
                    if (str[1]) { username = ""; }
                    if (str[0] == "0") {
                        $.ajax({
                            type: 'post',
                            cache: false,
                            dataType: 'text',
                            url: 'Handlers/LoginHandler.ashx',
                            data: { username: username, password: password, dogId: str[1], type: "Manager" },
                            success: function (result) {
                                if (result == "success") {
                                    var width = $(window).width();
                                    var height = $(window).height();
                                    parent.document.location.href = "Mainframe.aspx";
                                }
                                else {
                                    _dialog("error", result);
                                    //radalert(msg, 300, 150, '提示');
                                }
                            },
                            error: function () {
                                _dialog("error", '登录失败，请与客服联系！');
                            },
                            beforeSend: function () {
                                _dialog("waitting", "正在登录中,请稍后...");
                                $("#btnLogin").attr("disabled", true);
                            },
                            complete: function () {
                                $.ligerDialog.closeWaitting();
                                $("#btnLogin").attr("disabled", false);
                            }
                        });
                        //                        $.post("Handlers/LoginHandler.ashx", { username: username, password: password, dogId: str[1], type: "Manager" }, function (msg) {
                        //                            if (msg == "success") {
                        //                                var width = $(window).width();
                        //                                var height = $(window).height();
                        //                                parent.document.location.href = "Mainframe.aspx";
                        //                            }
                        //                            else {
                        //                                $.ligerDialog.error(msg);
                        //                                //radalert(msg, 300, 150, '提示');
                        //                            }
                        //                        });
                    }
                    else {
                        _dialog("error", unescape(str[1]));
                        //radalert(unescape(str[1]), 300, 150, '提示');
                    }
                }

            });
            $("#expertLogin").click(function () {
                var idNum = $("#inp_idnum").val();
                var password = $('#inp_password').val();
                var message;
                var dogId;
                if (idNum == "") {
                    _dialog("error", '身份证号码不能为空');
                    //radalert('用户名或密码不能为空', 300, 150, '提示');
                }
                else {
                    if (!isIdCardNo(idNum, message)) { _dialog("error", '请输入正确的身份证号码！'); return false; }
                    if (!password) { _dialog("error", '请输入密码！'); return false; }
                    if (str[0] == "0") {
                        $.ajax({
                            type: 'post',
                            cache: false,
                            dataType: 'text',
                            url: 'Handlers/LoginExpertHandler.ashx',
                            data: { idnum: idNum, passWord: password, dogId: str[1], type: "Expert" },
                            success: function (result) {
                                if (result == "success") {
                                    parent.document.location.href = "Mainframe.aspx";
                                }
                                else {
                                    _dialog("error", result);
                                    //radalert(msg, 300, 150, '提示');
                                }
                            },
                            error: function () {
                                _dialog("error", '登录失败，请与客服联系！');
                            },
                            beforeSend: function () {
                                _dialog("waitting", "正在登录中,请稍后...");
                                $("#btnLogin").attr("disabled", true);
                            },
                            complete: function () {
                                $.ligerDialog.closeWaitting();
                                $("#btnLogin").attr("disabled", false);
                            }
                        });
                        //                        $.post("Handlers/LoginHandler.ashx", { username: username, password: password, dogId: str[1], type: "User" }, function (msg) {
                        //                            if (msg == "success") {
                        //                                parent.document.location.href = "Mainframe.aspx";
                        //                            }
                        //                            else {
                        //                                $.ligerDialog.error(msg);
                        //                                //radalert(msg, 300, 150, '提示');
                        //                            }
                        //                        });
                    }
                    else {
                        _dialog("error", unescape(str[1]));
                        //radalert(unescape(str[1]), 300, 150, '提示');
                    }
                }
            });
            $(".a_qq").click(function () {
                window.location.href = "AccountHelp/Help.aspx";
            })
        });

        function btnSendClientClick() {
            var self = $("#btnSend");
            var tel = $("#inp_phonenum").val();
            var idNum = $("#inp_idnum").val();
            var message;
            if (!idNum) { _dialog("error", '身份证号码不能为空！'); return false; }
            if (!isIdCardNo(idNum, message)) { _dialog("error", '请输入正确的身份证号码！'); return false; }
            if (!tel) { _dialog("error", '手机号码不能为空！'); return false; }
            if (!isMobile(tel)) { _dialog("error", '请输入正确的手机号码！'); return false; }

            self.attr("disabled", true);
            $.post("LoginExpert.aspx", { idNum: idNum, mobile: tel, FuncType: "CheckSendRight" },
                                        function (res) {
                                            if (res == "-1") { _dialog("waitting", '请不要在短时间内连续发送验证码！'); self.attr("disabled", true); return false; }
                                            if (res == "101") { _dialog("error", '用户名或手机号码不正确！'); self.removeAttr("disabled"); return false; }
                                            var msg = "";
                                            if (res == "90") { msg = "已发送"; }
                                            else {
                                                msg = "您还需等待";
                                            }
                                            if (res != "101") {
                                                SetTimer(self, res, msg, function () {
                                                    self.removeAttr("disabled");
                                                    self.val("发送至手机验证码");
                                                });
                                            }
                                        }, "json");

        }
        //定时器
        function SetTimer(obj, time, msg, fn) {
            obj = $(obj);
            time = time || 60;
            obj.attr("disabled", true);
            obj.val(msg + --time);
            var i = setInterval(function () {
                obj.val(msg + --time);
                if (time <= 0) {
                    clearInterval(i);
                    fn();
                };
            }, 1000);
        }

        function isMobile(s) {
            var patrn = /^0{0,1}(1[3-8])[0-9]{9}$/;
            if (!patrn.exec(s)) return false
            return true
        }

        function isCode(s) {
            var patrn = /^[0-9]{6}$/;
            if (!patrn.exec(s)) return false
            return true
        }

        function isIdCardNo(num, message) {
            num = num.toUpperCase();
            //身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X。   
            if (!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(num))) {
                message = '输入的身份证号长度不对，或者号码不符合规定！/n15位号码应全为数字，18位号码末位可以为数字或X。';
                return false;
            }
            //校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。 
            //下面分别分析出生日期和校验位 
            var len, re;
            len = num.length;
            if (len == 15) {
                re = new RegExp(/^(\d{6})(\d{2})(\d{2})(\d{2})(\d{3})$/);
                var arrSplit = num.match(re);

                //检查生日日期是否正确 
                var dtmBirth = new Date('19' + arrSplit[2] + '/' + arrSplit[3] + '/' + arrSplit[4]);
                var bGoodDay;
                bGoodDay = (dtmBirth.getYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
                if (!bGoodDay) {
                    //alert("输入的身份证号里出生日期不对!");
                    message = '输入的身份证号里出生日期不对！';
                    return false;
                }
                else {
                    //将15位身份证转成18位 
                    //校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。 
                    var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
                    var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
                    var nTemp = 0, i;
                    num = num.substr(0, 6) + '19' + num.substr(6, num.length - 6);
                    for (i = 0; i < 17; i++) {
                        nTemp += num.substr(i, 1) * arrInt[i];
                    }
                    num += arrCh[nTemp % 11];
                    return num;
                }
            }
            if (len == 18) {
                re = new RegExp(/^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$/);
                var arrSplit = num.match(re);

                //检查生日日期是否正确 
                var dtmBirth = new Date(arrSplit[2] + "/" + arrSplit[3] + "/" + arrSplit[4]);
                var bGoodDay;
                bGoodDay = (dtmBirth.getFullYear() == Number(arrSplit[2])) && ((dtmBirth.getMonth() + 1) == Number(arrSplit[3])) && (dtmBirth.getDate() == Number(arrSplit[4]));
                if (!bGoodDay) {

                    //alert("输入的身份证号里出生日期不对！");
                    message = '输入的身份证号里出生日期不对！';
                    return false;
                }
                else {
                    //检验18位身份证的校验码是否正确。 
                    //校验位按照ISO 7064:1983.MOD 11-2的规定生成，X可以认为是数字10。 
                    var valnum;
                    var arrInt = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2);
                    var arrCh = new Array('1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2');
                    var nTemp = 0, i;
                    for (i = 0; i < 17; i++) {
                        nTemp += num.substr(i, 1) * arrInt[i];
                    }
                    valnum = arrCh[nTemp % 11];
                    if (valnum != num.substr(17, 1)) {
                        message = '18位身份证的校验码不正确！应该为：' + valnum;
                        return false;
                    }
                    return num;
                }
            }
            return false;
        }
    </script>
    <style type="text/css">
        .tab
        {
            border-collapse: collapse;
        }
        .tab a
        {
            text-decoration: none;
            color: #1269a1;
        }
        .tab a:hover
        {
            text-decoration: underline;
        }
        .bj_btn
        {
            line-height: 30px;
            height: 30px;
            background: url(images/bj_btn_bg.jpg) repeat-x;
            width: 130px;
            text-align: center;
            margin-left: 10px;
            float: left;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div class="header">
            <div class="logo">
            </div>
        </div>
        <div class="main">
            <div class="banner">
                <div class="con">
                    <%--<div id="bg" class="xixi2">
                        <div id="font1" class="tab1" onclick="setTab03Syn(1);document.getElementById('bg').className='xixi1'">
                            主管部门登录</div>
                        <div id="font2" class="tab2" onclick="setTab03Syn(2);document.getElementById('bg').className='xixi2'">
                            专家用户登录</div>
                    </div>--%>
                    <div id="TabTab03Con1">
                        <ul class="input_test">
                            <li>
                                <input id="inp_name" class="input_out" type="text" onfocus="this.className='input_on';this.onmouseout=''"
                                    onblur="this.className='input_off';this.onmouseout=function(){this.className='input_out'};"
                                    onmousemove="this.className='input_move'" onmouseout="this.className='input_out'"
                                    style="background: url(images/yh.gif) 5px center no-repeat; padding-left: 26px;
                                    width: 212px; font-family: Verdana, Geneva, sans-serif; font-size: 14px;" />
                            </li>
                            <li>
                                <input id="inp_email" class="input_out" name="" type="password" onfocus="this.className='input_on';this.onmouseout=''"
                                    onblur="this.className='input_off';this.onmouseout=function(){this.className='input_out'};"
                                    onmousemove="this.className='input_move'" onmouseout="this.className='input_out'"
                                    style="background: url(images/mm.gif) 5px center no-repeat; padding-left: 26px;
                                    width: 212px; font-family: Verdana, Geneva, sans-serif; font-size: 14px;" />
                            </li>
                        </ul>
                        <div class="btn">
                            <a id="zhuguanLogin" style="cursor: pointer;">登 录</a></div>
                        <div class="btm">
                            <%--<ul>
                                <li><a href="#" class="Register">
                                    <img src="images/zc.jpg" width="54" height="44" alt="" /></a><p class="wenzi">
                                        <a href="#" class="Register">注册用户</a></p>
                                </li>
                                <li><a href="Person/PersonExpertForgetPwd.aspx">
                                    <img src="images/wjmm.jpg" width="54" height="44" alt="" /></a><p class="wenzi">
                                        <a href="Person/PersonExpertForgetPwd.aspx">忘记密码</a></p>
                                </li>
                                <li><a class="a_qq" style="cursor: pointer;" href="AccountHelp/Help.aspx">
                                    <img src="images/qq.jpg" width="54" height="44" alt="" /></a><p class="wenzi">
                                        <a class="a_qq" style="cursor: pointer;" href="AccountHelp/Help.aspx">系统客服</a></p>
                                </li>
                                <li><a href="#">
                                    <img src="images/bz.jpg" width="54" height="44" alt="" /></a><p class="wenzi">
                                        <a href="#">帮助</a></p>
                                </li>
                            </ul>--%>
                            <div class="clear">
                            </div>
                        </div>
                    </div>
                    <%--<div id="TabTab03Con2">
                        <ul class="input_test">
                            <li>
                                <input id="inp_idnum" class="input_out" type="text" onfocus="this.className='input_on';this.onmouseout='';if(value==defaultValue){value='';this.style.color='#000'}"
                                    onblur="this.className='input_off';this.onmouseout=function(){this.className='input_out'};if(!value){value=defaultValue;this.style.color='#999'}"
                                    onmousemove="this.className='input_move'" onmouseout="this.className='input_out'"
                                    style="background: url(images/yh.gif) 5px center no-repeat; padding-left: 26px;
                                    width: 212px; font-family: Verdana, Geneva, sans-serif; font-size: 14px; color: #999999"
                                    value="请输入身份证号码" />
                            </li>
                            <li>
                                <input id="inp_password" class="input_out" name="" type="password" onfocus="this.className='input_on';this.onmouseout=''"
                                    onblur="this.className='input_off';this.onmouseout=function(){this.className='input_out'};"
                                    onmousemove="this.className='input_move'" onmouseout="this.className='input_out'"
                                    style="background: url(images/mm.gif) 5px center no-repeat; padding-left: 26px;
                                    width: 212px; font-family: Verdana, Geneva, sans-serif; font-size: 14px;" />
                            </li>
                            <li>
                                <input id="inp_code" class="input_out" name="" type="password" onfocus="this.className='input_on';this.onmouseout=''"
                                    onblur="this.className='input_off';this.onmouseout=function(){this.className='input_out'};"
                                    onmousemove="this.className='input_move'" onmouseout="this.className='input_out'"
                                    style="background: url(images/mm.gif) 5px center no-repeat; padding-left: 26px;
                                    width: 70px; font-family: Verdana, Geneva, sans-serif; font-size: 14px; float: left;
                                    margin-left: 45px" />
                                <input onclick="btnSendClientClick()" id="btnSend" type="button" class="bj_btn" value="发送验证码至手机" />
                            </li>
                        </ul>
                        <div class="key">
                            <asp:DropDownList ID="CertList2" runat="server">
                            </asp:DropDownList>
                        </div>
                        <div class="btn">
                            <a id="expertLogin" style="cursor: pointer;">登 录</a></div>
                        <div class="btm">
                            <ul>
                                <li><a href="#" class="Register">
                                    <img src="images/zc.jpg" width="54" height="44" alt="" /></a><p class="wenzi">
                                        <a href="#" class="Register">注册用户</a></p>
                                </li>
                                <li><a href="Person/PersonExpertForgetPwd.aspx">
                                    <img src="images/wjmm.jpg" width="54" height="44" alt="" /></a><p class="wenzi">
                                        <a href="Person/PersonExpertForgetPwd.aspx">忘记密码</a></p>
                                </li>
                                <li><a class="a_qq" style="cursor: pointer;" href="AccountHelp/Help.aspx">
                                    <img src="images/qq.jpg" width="54" height="44" alt="" /></a><p class="wenzi">
                                        <a class="a_qq" style="cursor: pointer;" href="AccountHelp/Help.aspx">系统客服</a></p>
                                </li>
                            </ul>
                            <div class="clear">
                            </div>
                            <div id="RegisterEdit" style="display: none">
                                如果您要修改、查看注册信息或下载数字证书，请点击 <a id="A1" href="http://123.234.82.27/oldytbm/Member/ApplyCertificate">
                                    修改</a>
                            </div>
                        </div>
                    </div>--%>
                </div>
                <div class="clear">
                </div>
            </div>
        </div>
        <ucUserRight:UCUserRight ID="UCUserRight1" runat="server" />
    </div>
    <%--<div id="divQQ" style="z-index: 999; right: 40px; visibility: visible; width: 76px;
        position: absolute; top: 200px; height: 203px; display: none;">
        <table width="100" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td colspan="3" style="font-size: 0px;">
                    <img src="Images/QQ_3.gif" width="106" height="71" border="0" usemap="#Map">
                </td>
            </tr>
            <tr>
                <td width="4" height="78" background="images/QQ_8.gif">
                </td>
                <td width="98" align="center" bgcolor="#FFFFFF">
                    <table width="100%" cellspacing="0" cellpadding="3" class="tab">
                        <tr>
                            <td width="36%" height="22">
                                <div align="center">
                                    <img src="http://wpa.qq.com/pa?p=1:1215554807:4" border='0' width="22" height="17"></div>
                            </td>
                            <td width="64%" height="22">
                                <a href="http://wpa.qq.com/msgrd?V=1&amp;Uin=1215554807&amp;Site=QQ咨询&amp;Menu=yes"
                                    target='_blank'>QQ客服1</a>
                            </td>
                        </tr>
                        <tr>
                            <td height="22">
                                <div align="center">
                                    <img src="http://wpa.qq.com/pa?p=1:2385016278:4" border='0' width="22" height="17"></div>
                            </td>
                            <td height="22">
                                <a href="http://wpa.qq.com/msgrd?V=1&amp;Uin=2385016278&amp;Site=QQ咨询&amp;Menu=yes"
                                    target='_blank'>QQ客服2</a>
                            </td>
                        </tr>
                        <tr>
                            <td height="22">
                                <div align="center">
                                    <img src="http://wpa.qq.com/pa?p=1:1731434335:4" border='0' width="22" height="17"></div>
                            </td>
                            <td height="22">
                                <a href="http://wpa.qq.com/msgrd?V=1&amp;Uin=1731434335&amp;Site=QQ咨询&amp;Menu=yes"
                                    target='_blank'>QQ客服3</a>
                            </td>
                        </tr>
                    </table>
                </td>
                <td width="4" background="Images/QQ_7.gif">
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <img src="Images/QQ_12.gif" width="106" height="44">
                </td>
            </tr>
        </table>
    </div>--%>
    <map name="Map" id="Map">
        <area shape="poly" coords="78,3,82,17,90,18,97,13,98,8,98,3,77,3" href="javascript:"
            onclick="divQQ.style.display='none';" title="关闭" />
    </map>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true"
        Skin="WebBlue">
    </telerik:RadWindowManager>
    </form>
    <%--老专家登陆模块--%>
    <%--<div class="con" style='width: 350px; position: fixed; top: 23%; left: 200px; height: 400px;
        font-size: 18px; text-align: center; background-color: rgb(255, 255, 255);'>
        <div style="width: 350px; height: 87px; position: absolute; top: -87px;">
            <img src="images/login_g_ts.png" width="350" height="87" style="margin-left: 176px;">
            <img src="images/login_g_top.png" style="margin-left: 207px;">
        </div>
        <div id="Div5" style="height: 287px;">
            <span id="EmpInfoInput" style="width: 239px; height: 50px; top: 65px; left: 47px;
                position: absolute; color: White; background-image: url(Images/242_54_blue.jpg);
                line-height: 48px; cursor: pointer; font-size: 23px; padding-left: 17px;">专家身份确认入口
                <span style="width: 20px; height: 50px; position: absolute; right: 0px; top: 0px;
                    background-image: url(Images/242_54_blue.jpg); background-position: top right;">
                </span></span><span id="czsm" style='width: 256px; line-height: 33px; height: 34px;
                    top: 155px; left: 47px; position: absolute; color: white; font-size: 16px; background-image: url(Styles/skins/expert/images/left_title.jpg);
                    cursor: pointer;'>系统操作说明</span><span id="gfkTel" style='width: 256px; line-height: 33px;
                        height: 34px; top: 205px; left: 47px; position: absolute; font-size: 16px; color: white;
                        background-image: url(Styles/skins/expert/images/left_title.jpg); cursor: pointer;'>
                        咨询联系电话</span>
        </div>
        <div class="btm" style="height: 113px; margin-top: 0px; padding-top: 0px; width: 100%;">
        </div>
    </div>--%>
</body>
<script type="text/javascript">
    var appid = '<%=SystemID %>'; //97;
</script>
</html>
